<?php

namespace App\Listeners;

use App\Events\UserCourseChangeEvent;
use App\Service\Redis\RedisBaseService;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;

class UserCourseChangeListener
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param UserCourseChangeEvent $event
     * @return void
     * @throws \RedisException
     */
    public function handle(UserCourseChangeEvent $event)
    {
        $redisBaseService = new RedisBaseService();
        $redisBaseService->updateUserHadCourseIds($event->userId);
        $redisBaseService->deleteUserWrongOrCollectQuestionAllCache($event->userId);
    }
}
